<template>
  <div>
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='search' v-ref:criteria>
        <validator name='v' partial>
        <div  class="form-inline auto" >
          <div class="form-group">
            <div class="form-group" >
              <label for="f_subcompany">分公司：</label>
              <v-select id="f_subcompany"
              placeholder='请选择分公司'
              :value.sync="$parent.$parent.model.f_subcompany"
              :options='$parent.$parent.f_divisions'
              close-on-select clear-button></v-select>
            </div>
            <!-- <div class="form-group">
              <label for="f_check_type">用户类型：</label>
              <v-select id="f_check_type"
              placeholder='请选择用户类型'
              :value.sync="$parent.$parent.model.f_check_type"
              :options='$parent.$parent.user_types'
              close-on-select clear-button></v-select></v-select>
            </div> -->
            <div class="form-group">
              安检时间 从:
              <datepicker id="startdate"
                v-model='model.date1'
                :value.sync="model.date1"
                :disabled-days-of-Week="[]"
                :format="'yyyy-MM-dd'"
                :show-reset-button="reset">
              </datepicker>
            </div>
            <div class="form-group">
              到:
              <datepicker id="startdate"
              v-model='model.date2'
              :value.sync="model.date2"
                :disabled-days-of-Week="[]"
                :format="'yyyy-MM-dd'"
                :show-reset-button="reset">
              </datepicker>
            </div>
            <div class="form-group">
              年限:
              <input type="number" class="form-control"
              placeholder='请输入数字' v-model="$parent.$parent.model.year">
            </div>
            <div class="form-group">
              <label for="f_maker">壁挂炉品牌</label>
              <v-select id="f_maker"
              placeholder='请选择壁挂炉品牌'
              :value.sync="$parent.$parent.model.f_maker"
              :options='$parent.$parent.brands'
              close-on-select clear-button></v-select>
            </div>
            <div class="form-group">
              <button class="btn btn-success width-80" @click="search()">查询</button>
            </div>
          </div>
        </div>
        </validator>
      </criteria>
      <data-grid :model="model" partial='list' v-ref:grid>
        <template partial='head'>
          <tr>
            <th>用户姓名</th>
            <th>用户ID</th>
            <th>灶具品牌</th>
            <th>出厂日期</th>
          </tr>
        </template>
        <template partial='body'>
          <td>{{row.f_user_name}}</td>
          <td>{{row.f_user_id}}</td>
          <td>{{row.f_brand }}</td>
          <td>{{row.f_making_date}}</td>
        </template>
      </data-grid>
    </criteria-paged>
  </div>
</template>

<script>
import { PagedList } from 'vue-client'
import Vue from 'vue'
import AppData from '../../stores/AppData'
export default {
  title: '居民壁挂炉使用情况',
  data () {
    let model = new PagedList('rs/sql/壁挂炉使用情况', 20,
      {date1: 'this.model.date1', date2: 'this.model.date2',
      year: 'this.year', f_subcompany: 'this.f_subcompany[0]',
      f_check_type: 'this.f_check_type[0]', f_brand: 'this.f_maker[0]'})
    model.f_subcompany = [Vue.f_subcompany]
    model.f_check_type = ['居民']
    model.f_maker = ['']
    model.date1 = ''
    model.date2 = ''
    model.year = 6
    return {
      model: model
      // f_divisions: Vue.f_subcompany != '' ? [{label: Vue.f_subcompany, value: Vue.f_subcompany}]: this.$getParams('安检系统用子公司', [{label:'请选择分公司',value:''}]),
      // user_types: this.$getParams('安检用户类型', [{label:'请选择用户类型',value:''}]),
      // brands: this.$getParams('壁挂炉品牌', [{label:'请选择壁挂炉品牌',value:''}])
    }
  },
  computed: {
    brands () {
      return [{label: '全部', value: ''}, ...AppData.getParam('壁挂炉品牌')]
    },
    f_divisions () {
      return [{label: '全部', value: ''}, ...AppData.getParam('分公司')]
    }
  }
}
</script>
